package com.moss.cloud.base.biz.controller;

import com.moss.cloud.base.api.model.from.TenantConfigFrom;
import com.moss.cloud.base.biz.service.ITenantConfigService;
import com.moss.cloud.common.core.constant.ServiceList;
import com.moss.cloud.common.core.model.Result;
import com.moss.cloud.common.security.annotation.SysLog;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


@RestController
@RequestMapping(ServiceList.BASE + "/tenantConfig")
public class TenantConfigController {
    private final ITenantConfigService tenantConfigService;

    public TenantConfigController(ITenantConfigService tenantConfigService) {
        this.tenantConfigService = tenantConfigService;
    }

    /**
     * 查询租户配置列表
     *
     * @return
     */
    @PostMapping("/tenantConfList")
    @SysLog(serverName = ServiceList.MOSS_CLOUD_BASE, operation = "查询租户配置列表")
    public Result<?> tenantConfList() {
        return Result.success(tenantConfigService.tenantConfList());
    }

    /**
     * 租户更新配置
     *
     * @param tenantConfigFrom
     * @return
     */
    @PostMapping("/updateConfig")
    @SysLog(serverName = ServiceList.MOSS_CLOUD_BASE, operation = "租户更新配置")
    public Result<?> updateConfig(@RequestBody @Validated TenantConfigFrom tenantConfigFrom){
        return Result.success(tenantConfigService.updateConfig(tenantConfigFrom));
    }

}
